package com.csx.framework.springboot.sample.event;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 通过实现接口来自定义事件监听器
 * @author cuisongxu
 * @date 2024/2/27 周二 12:56
 */
@Component
public class CustomApplicationEventListener implements ApplicationListener<CustomApplicationEvent> {

    @Override
    public void onApplicationEvent(CustomApplicationEvent event) {
        Object source = event.getSource();
        // 模拟事件处理异常
//        int i = 1/ 0;
        System.out.println("CustomApplicationEventListener 接收事件CustomApplicationEvent， 事件源: " + source);
    }
}
